package gradle.mybatis.common.utils;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import gradle.common.core.context.SpringApplicationContext;
import gradle.mybatis.common.config.SnowflakeConfig;

/**
 * SnowflakeUtils
 *
 * @author 1141193930@qq.com
 */
public class SnowflakeUtils {

    /**
     * 获取雪花算法
     */
    public static  Snowflake getSnowflake() {
        SnowflakeConfig snowflakeConfig = SpringApplicationContext.getBean(SnowflakeConfig.class);

        return IdUtil.getSnowflake(snowflakeConfig.getWorkerId(), snowflakeConfig.getDatacenterId());

    }

}
